import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GeneraVO, GeneraForm, GeneraQuery } from '@/api/genealogy/genera/types';

/**
 * 查询世代列表
 * @param query
 * @returns {*}
 */

export const listGenera = (query?: GeneraQuery): AxiosPromise<GeneraVO[]> => {
  return request({
    url: '/genealogy/genera/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询世代详细
 * @param id
 */
export const getGenera = (id: string | number): AxiosPromise<GeneraVO> => {
  return request({
    url: '/genealogy/genera/' + id,
    method: 'get'
  });
};

/**
 * 新增世代
 * @param data
 */
export const addGenera = (data: GeneraForm) => {
  return request({
    url: '/genealogy/genera',
    method: 'post',
    data: data
  });
};

/**
 * 修改世代
 * @param data
 */
export const updateGenera = (data: GeneraForm) => {
  return request({
    url: '/genealogy/genera',
    method: 'put',
    data: data
  });
};

/**
 * 删除世代
 * @param id
 */
export const delGenera = (id: string | number | Array<string | number>) => {
  return request({
    url: '/genealogy/genera/' + id,
    method: 'delete'
  });
};
